<html>
	<head>
		<script>

			function testSubmission(doId) {
				var url;
				var element
				
				if(doId) {
					element = document.getElementById("idElement");
					var id = element.value;
					url = "createproducts?id=" + id;
				}
				else {
					element = document.getElementById("nameElement");
					var name = element.value;
					url = "createproducts?name=" + name;
				}
				
				element = document.getElementById("templateElement");
				var template = element.value;
				url += "&template=" + template;
				
				submit("GET",url,null,downloadComplete);
			}
			
			
			function downloadComplete(result) {
				alert("Create complete");
			}

			function submit(method,url,body,onDownload) {

				var xmlhttp = new XMLHttpRequest();

				xmlhttp.onreadystatechange=function() {
					if (xmlhttp.readyState==4 && xmlhttp.status==200) {
						onDownload(xmlhttp.responseText);

					}
					else if(xmlhttp.readyState==4) {
						alert("Error in request, Status: " + xmlhttp.status);
					}
				}

				xmlhttp.open(method,url,true);
				xmlhttp.send(body);
			}

		</script>
	</head>
	<body>
		<h1>Product Test</h1>
		map template: <textarea id="templateElement" cols="31"></textarea><br>
		id: <textarea id="idElement" cols="31"></textarea>
		<input type="button" value="ID Test" onclick="testSubmission(true)"/><br>
		name: <textarea id="nameElement" cols="31"></textarea>
		<input type="button" value="Name Test" onclick="testSubmission(false)"/><br>
		
	</body>
</html>
